$(function() {

  slices.controller.init(
    '<%= @page.bson_id %>',
    {
      availableSlices: <%= raw Slices::AvailableSlices.all.to_json %>,
      availableContainers: <%= raw @layout.containers.to_json %>,

      mainTemplate: '<%= @page.main_template %>',
      metaTemplate: '<%= @page.meta_template %>',

      mainExtraTemplates: <%= raw @page.main_extra_templates.to_json %>,
      metaExtraTemplates: <%= raw @page.meta_extra_templates.to_json %>,

      super_user: <%= current_admin.super? %>,
      i18n: <%= Slices::Config.i18n? %>,

      loadPagePath: '/admin/pages/{{id}}.json?locale=<%= I18n.locale %>',
      savePagePath: '/admin/pages/{{id}}.json?locale=<%= I18n.locale %>',

      <% if @page.editing_entry_content_slices?(params[:entries]) %>
        mainTemplate: 'set_page_entry_content_main',
        metaTemplate: 'set_page_entry_content_meta',
        loadPagePath: '/admin/pages/{{id}}?locale=<%= I18n.locale %>&entries=1',
        savePagePath: '/admin/pages/{{id}}?locale=<%= I18n.locale %>&entries=1'
      <% end %>
    }
  );

});

